/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.util.conn;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author Pinds
 */
public class DataBaseConnection {

    private static Connection conn;

    /*
     * Get Conection untuk setiap terhubung dengan data Base.
     */
    public static Connection getConnection() {
        if (conn == null) {
            try {
                DriverManager.registerDriver(new com.mysql.jdbc.Driver());
                conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/emovie", "root", "");
            } catch (SQLException ex) {
                JOptionPane.showMessageDialog(null, "Data tidak valid", "Perhatian", JOptionPane.WARNING_MESSAGE);
            }
        }
        return conn;
    }
}
